package com.telefonica.bmws.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import org.apache.log4j.Logger;

public class ConnectionDAO {

	static String dbUser = "";
	static String dbPass = "";
	static String url = "";
	static String driverClassName = "";
	protected static Logger logger = Logger.getLogger(ConnectionDAO.class);

//	public static Connection ObtenerConexion() {
//		try {
//			Connection conn = getConnection();
//			return conn;
//		} catch (Exception e) {
//			logger.error("Problemas de creacion de objeto en iniciarConexiones(): " + e.toString());
//			return null;
//		}
//	}

	public static Connection ObtenerConexion() {
		try {
			dbUser = "bmovil";
			dbPass = "bmovil";
			url = "jdbc:oracle:thin:@localhost:1521:ORCL";
			Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
			Connection conn = (Connection) DriverManager.getConnection(url, dbUser, dbPass);
			return conn;

		} catch (Exception e) {
			logger.error("Problemas de creacion de objeto en iniciarConexiones(): " + e.toString());
			return null;

		}

	}

//	private static Connection getConnection() {
//		Connection connection = null;
//		try {
//			InitialContext context = new InitialContext();
//			DataSource dataSource = (DataSource) context.lookup("java:/BancaMovilWsDS");
//			connection = dataSource.getConnection();
//		} catch (NamingException e) {
//			e.printStackTrace();
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return connection;
//	}
}
